<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>MIC: Fichero Fuente comun/Socket.h</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MIC
   
   </div>
   <div id="projectbrief">Motor de Inteligencia de Comercio en tiempo real</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generado por Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Buscar');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Página&#160;principal</span></a></li>
      <li><a href="pages.html"><span>Páginas&#160;relacionadas</span></a></li>
      <li><a href="annotated.html"><span>Clases</span></a></li>
      <li class="current"><a href="files.html"><span>Archivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Buscar" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Lista&#160;de&#160;archivos</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('Socket_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">comun/Socket.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* </span>
<a name="l00002"></a>00002 <span class="comment"> * File:   Socket.h</span>
<a name="l00003"></a>00003 <span class="comment"> * Author: migue</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created on 26 de abril de 2012, 13:15</span>
<a name="l00006"></a>00006 <span class="comment"> */</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef SOCKET_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define SOCKET_H</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;netdb.h&gt;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;arpa/inet.h&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;Definiciones.h&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="keyword">class </span><a class="code" href="classMensaje.html">Mensaje</a>;
<a name="l00023"></a>00023 <span class="keyword">class </span><a class="code" href="classConsulta.html">Consulta</a>;
<a name="l00024"></a>00024 <span class="keyword">class </span><a class="code" href="classRespuesta.html">Respuesta</a>;
<a name="l00025"></a>00025 
<a name="l00033"></a><a class="code" href="classSocket.html">00033</a> <span class="keyword">class </span><a class="code" href="classSocket.html">Socket</a> {
<a name="l00034"></a>00034 <span class="keyword">public</span>:
<a name="l00039"></a>00039     <span class="keyword">explicit</span> <a class="code" href="classSocket.html#aecd84cd77e3c7906c9b6bc62eb139e94" title="Constructor para el Socket que recibe el puerto en donde se va a conectar.">Socket</a>(Puerto puerto);
<a name="l00040"></a>00040         
<a name="l00044"></a>00044     <span class="keyword">virtual</span> <a class="code" href="classSocket.html#aeac4eb6379a543d38ed88977d3b6630a" title="Destructor virtual de Socket.">~Socket</a>();
<a name="l00045"></a>00045     
<a name="l00050"></a>00050     <span class="keywordtype">void</span> <a class="code" href="classSocket.html#a4b072b1d4e02bb676b4d2bfc17bc252c" title="Intenta establecer una conexion con el huesped.">conectar</a>(<span class="keyword">const</span> std::string&amp; huesped);
<a name="l00051"></a>00051     
<a name="l00055"></a>00055     <span class="keywordtype">void</span> <a class="code" href="classSocket.html#a96467ca6d4fda8fb3d9fbc6818ec5c39" title="Enlaza el Socket para poder escuchar conexiones entrantes.">enlazar</a>();
<a name="l00056"></a>00056     
<a name="l00062"></a>00062     <a class="code" href="classSocket.html">Socket</a>* <a class="code" href="classSocket.html#a0dea5b749aa54a23dcdbfb72aceed3c0" title="Escucha una conexion entrante y retorna un Socket para realizar la comunicion con esta...">escucharConexion</a>();
<a name="l00063"></a>00063     
<a name="l00069"></a>00069     <span class="keywordtype">bool</span> <a class="code" href="classSocket.html#a9b61fa7f865eb17e727b1e08a8467274" title="Envia el mensaje atravez del socket, confirmando si fue enviado correctamente.">enviar</a>(<span class="keyword">const</span> <a class="code" href="classMensaje.html">Mensaje</a>&amp; mensaje);
<a name="l00070"></a>00070 
<a name="l00076"></a>00076     <span class="keywordtype">bool</span> <a class="code" href="classSocket.html#a820da69df857dabb200934da3a8a53ae" title="Se pone en espera a recibir una respuesta.">recibir</a>(<a class="code" href="classMensaje.html">Mensaje</a>&amp; mensaje);
<a name="l00077"></a>00077 
<a name="l00081"></a>00081     <span class="keywordtype">void</span> <a class="code" href="classSocket.html#adc70891a239124b75ceb11275464e981" title="Cierra la conexion con el huesped.">desconectar</a>();
<a name="l00082"></a>00082     
<a name="l00088"></a>00088     <span class="keywordtype">bool</span> <a class="code" href="classSocket.html#acd86b2a177083a141c61afeab3816fab" title="Retorna un bool indicando si el socket se encuentra en estado de conectado.">conectado</a>();
<a name="l00089"></a>00089 <span class="keyword">private</span>:
<a name="l00094"></a>00094     <span class="keyword">explicit</span> <a class="code" href="classSocket.html#aecd84cd77e3c7906c9b6bc62eb139e94" title="Constructor para el Socket que recibe el puerto en donde se va a conectar.">Socket</a>(<span class="keywordtype">int</span> fd);
<a name="l00095"></a>00095     
<a name="l00102"></a>00102     <span class="keywordtype">bool</span> recibirDatos(std::string&amp; datos);
<a name="l00103"></a>00103 
<a name="l00107"></a>00107     <a class="code" href="classSocket.html#aecd84cd77e3c7906c9b6bc62eb139e94" title="Constructor para el Socket que recibe el puerto en donde se va a conectar.">Socket</a>(<span class="keyword">const</span> <a class="code" href="classSocket.html">Socket</a>&amp; orig) {}
<a name="l00108"></a>00108     <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <a class="code" href="classSocket.html">Socket</a>&amp; orig) {}
<a name="l00109"></a>00109     
<a name="l00113"></a>00113     <span class="keywordtype">void</span> inicializar();
<a name="l00114"></a>00114     
<a name="l00115"></a>00115     <span class="keyword">struct </span>timeval _timeout;
<a name="l00116"></a>00116     <span class="keywordtype">int</span> _fd;
<a name="l00117"></a>00117     <span class="keyword">struct </span>sockaddr_in _direccion;
<a name="l00118"></a>00118     Puerto _puerto;
<a name="l00119"></a>00119     <span class="keywordtype">bool</span> _conectado;
<a name="l00120"></a>00120     <span class="keywordtype">bool</span> _enlazado;
<a name="l00121"></a>00121 };
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 <span class="preprocessor">#endif  </span><span class="comment">/* SOCKET_H */</span>
<a name="l00124"></a>00124 
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>Todo</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Clases</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Funciones</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumeraciones</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>Socket.h</b>      </li>

    <li class="footer">Generado el Martes, 10 de Julio de 2012 15:15:02 para MIC por
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
